<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}
if(isset($_POST['sub']) && $_POST['sub']=="save"){
    $oldpassword=trim($_POST['oldPassword']);
    $newPassword=trim($_POST['newPassword']);
    $rnewPassword=trim($_POST['rnewPassword']);
    
    if(trim($oldpassword)==""){
        jumpajax('300','旧密码必须输入！','');
    }
    if($newPassword<>$rnewPassword){
        jumpajax('300','两次新密码输入不同！','');
    }    
    $name=$_SESSION['EZ_Admin']['name'];
    $admin=$ezhand->select('adminuser','*','adminname="'.$name.'" and adminpass="'.deep_jm($oldpassword).'"');
    if(empty($admin)){
        jumpajax('300','旧密码错误!','','');
        
    }
    if($admin['id']>0){
        $data=array("adminpass"=>deep_jm($newPassword));
        $ezhand->update('adminuser',$data,'id='.$admin['id']);
        
        jumpajax('200','修改成功','','closeCurrent');    
    }else{
        
        jumpajax('300','旧密码错误!','','');
    }
    
    
}
?>